package test04.demo00.tx02;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class MainTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable myCallable=new MyCallable(1,100);
        MyCallable myCallable1=new MyCallable(101,900);
        MyCallable myCallable2=new MyCallable(901,1000);

        FutureTask<Integer> futureTask=new FutureTask<>(myCallable);
        FutureTask<Integer> futureTask1=new FutureTask<>(myCallable1);
        FutureTask<Integer> futureTask2=new FutureTask<>(myCallable2);

        Thread thread=new Thread(futureTask);
        Thread thread1=new Thread(futureTask1);
        Thread thread2=new Thread(futureTask2);

        thread.start();
        thread1.start();
        thread2.start();

        Integer s = futureTask.get() + futureTask1.get() + futureTask2.get();
        System.out.println(s);
    }
}
